<?php
/*
Template Name: Front Page
*/
get_header(); 

$id = get_post_meta($post->ID, 'display_front_page', true);

global $wpdb;
$display_fp_elements_query = "SELECT * FROM `".$wpdb->prefix."lazar_fp_elements` WHERE `parent_id` = '$id' ORDER BY `order`";
$display_fp_elements = $wpdb->get_results($display_fp_elements_query);

//to save the content because we will overwrite WP_QUERY
if ( have_posts() ) while ( have_posts() ) : the_post(); 

    ob_start();
	the_content();
	$the_page_content = ob_get_clean();

	$the_page_title   = get_the_title();

endwhile;



if ( $display_fp_elements != '' )
{
	$horizontal_splitter = 0;
	//$after_posts = false;
	$next_element_is_active = false;
	
	echo '<section id="content_wrapper" class="clearfix mk_slider"'; if ( get_option('slider_active') != 'yes' ) echo 'style="margin-top: 30px;"'; echo'>';
	foreach ($display_fp_elements as $fp_element)
	{
		$next_element_is_active = false;
		// here we determine whether the current element is active / not so we know whether to add a splitter or not if length > 0.5
		switch ($fp_element->type)
		{
			case 'intro':        if ( get_option( 'enable_intro_'.$fp_element->parent_id ) == 'yes' )        $next_element_is_active = true; break;
			case 'posts':        if ( get_option( 'enable_posts_'.$fp_element->parent_id ) == 'yes' )        $next_element_is_active = true; break;
			case 'blog':         if ( get_option( 'enable_blog_'.$fp_element->parent_id ) == 'yes' )         $next_element_is_active = true; break;
			case 'features':     if ( get_option( 'enable_features_'.$fp_element->parent_id ) == 'yes' )     $next_element_is_active = true; break;
			case 'slideshow':    if ( get_option( 'enable_slideshow_'.$fp_element->parent_id ) == 'yes' )    $next_element_is_active = true; break;
			case 'news':         if ( get_option( 'enable_news_'.$fp_element->parent_id ) == 'yes' )         $next_element_is_active = true; break;
			case 'tabs':         if ( get_option( 'enable_tabs_'.$fp_element->parent_id ) == 'yes' )         $next_element_is_active = true; break;
			case 'testimonials': if ( get_option( 'enable_testimonials_'.$fp_element->parent_id ) == 'yes' ) $next_element_is_active = true; break;
			case 'contact':      if ( get_option( 'enable_contact_'.$fp_element->parent_id ) == 'yes' )      $next_element_is_active = true; break;
			case 'custom':       if ( get_option( 'enable_custom_'.$fp_element->parent_id ) == 'yes' )       $next_element_is_active = true; break;
			case 'the_content':  if ( get_option( 'enable_the_content_'.$fp_element->parent_id ) == 'yes' )  $next_element_is_active = true; break;
		}
				
		if ( $horizontal_splitter > 0.5 && ( $fp_element->type != 'posts' && $fp_element->type != 'features' ) && $next_element_is_active == true )
		{
			echo '<div class="horizontal_splitter_fpm"></div>';
			$horizontal_splitter = 0;
		}
		
		// this reset after the insertion of the splitter allows the splitter to NOT be inserted and then resets the aftr_posts variable
		/*if ( $after_posts == true )
			$after_posts = false;*/
		
		switch ($fp_element->type)
		{
			case 'intro':
				$enable_intro = get_option( 'enable_intro_'.$fp_element->parent_id );
				if ( $enable_intro == 'yes' )
				{
					$horizontal_splitter += 1;
					
					echo '<div id="welcome_div">';
						echo '<div id="welcome_message" class="clearfix">';
							if ( get_option( 'second_message_'.$fp_element->parent_id ) == '' && get_option( 'button_text_'.$fp_element->parent_id) == '' )
							{
								echo '<div id="welcome_text_no_button">';
									echo get_option( 'first_message_'.$fp_element->parent_id );
								echo '</div>';
							}
							
							if ( get_option( 'second_message_'.$fp_element->parent_id ) == '' && get_option( 'button_text_'.$fp_element->parent_id ) != '' )
							{
								echo '<div id="welcome_text">';
									echo get_option( 'first_message_'.$fp_element->parent_id );
								echo '</div>';
								echo '<a class="welcome_button_link" href="'.get_option( 'button_url_'.$fp_element->parent_id, '#' ).'"><div id="welcome_button">'.get_option( 'button_text_'.$fp_element->parent_id ).'</div></a>';
							}
							
							if ( get_option( 'second_message_'.$fp_element->parent_id ) != '' && get_option( 'button_text_'.$fp_element->parent_id ) == '' ) 
							{
								echo '<div id="welcome_text_first_no_button">';
									echo get_option( 'first_message_'.$fp_element->parent_id );
								echo '</div>';
								echo '<div id="welcome_text_second_no_button">';
									echo get_option( 'second_message_'.$fp_element->parent_id );
								echo '</div>';
							}
							
							if ( get_option( 'second_message_'.$fp_element->parent_id ) != '' && get_option( 'button_text_'.$fp_element->parent_id ) != '' ) 
							{	echo '<div style="float:left; width: 700px;">';
									echo '<div id="welcome_text_first">';
										echo get_option( 'first_message_'.$fp_element->parent_id );
									echo '</div>';
									echo '<div id="welcome_text_second">';
										echo get_option( 'second_message_'.$fp_element->parent_id );
									echo '</div>';
								echo '</div>';
								echo '<a class="welcome_button_link" href="'.get_option( 'button_url_'.$fp_element->parent_id, '#' ).'"><div id="welcome_button">'.get_option( 'button_text_'.$fp_element->parent_id ).'</div></a>';
							}
						echo '</div>';
					echo '</div>';
				}
			break;
												
			case 'posts':
				$enable_posts = get_option( 'enable_posts_'.$fp_element->parent_id );
				if ( $enable_posts == 'yes' )
				{
					$horizontal_splitter += 1;
					
					echo '<div class="front_page_element full_width_element">';

						$current_categories = get_option( 'post_categories_'.$fp_element->parent_id );
						$posts_per_page = get_option( 'posts_count_'.$fp_element->parent_id, '3' );
						$wp_query = new WP_Query('post_type=post&posts_per_page='.$posts_per_page.'&cat='.$current_categories);
						
						global $more;
						$more = 0;
						$rel_fp = '';
							
						$article_margin = 0;
						if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post();
							
							if ( has_post_thumbnail() ) $thumbnail_src = wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) );
							
							$link = get_permalink();
							
							$column_class = 'column_with_sidebar_2_col';
							$thumbnail_size = 'w=290&amp;h=290;';
							
							$image_source = get_template_directory_uri().'/includes/timthumb.php?src='.$thumbnail_src.'&amp;'.$thumbnail_size.'&amp;zc=1&amp;q=100';
							
							echo '<article class="posts"'; if ( $article_margin != 2 ) echo ' style="margin-right: 45px;"'; echo '>';
								echo '<div class="heading">';
									echo'<h3>'; echo the_title(); echo'</h3>';
								echo '</div>';
								echo '<div class="front_page_picture">';
									echo '<a title="';  echo the_title(); echo '" href="'.$link.'">';
										echo '<img src="'.$image_source.'" alt="'; echo the_title(); echo '" />';
										echo '<span></span>';
									echo '</a>';
								echo '</div>';
								echo '<div class="text" style="position: relative; z-index: 2;">';
									the_content('');
								echo '</div>';
							echo '</article>';
							
							if ( $article_margin == 2 ) $article_margin = 0;
							$article_margin++;
						endwhile; endif;
				
					echo '</div>'; // END .front_page_element
					
					$after_posts = true;
				}
			break;
			
			case 'features':
				$enable_features = get_option( 'enable_features_'.$fp_element->parent_id );
				if ( $enable_features == 'yes' )
				{
					$horizontal_splitter += 1;
					
					$margin_class = '';
					if ( $horizontal_splitter == 0.5 )
						$margin_class = 'fp_element_margin_right';
					
					$class = 'full_width_element';
					
					echo '<div class="front_page_element full_width_element clearfix">';
					
						$features_count = 0;
						
						if ( get_option( 'feature_1_icon_'.$fp_element->parent_id ) != '' ) $features_count++;
						if ( get_option( 'feature_2_icon_'.$fp_element->parent_id ) != '' ) $features_count++;
						if ( get_option( 'feature_3_icon_'.$fp_element->parent_id ) != '' ) $features_count++;
						if ( get_option( 'feature_4_icon_'.$fp_element->parent_id ) != '' ) $features_count++;
						if ( get_option( 'feature_5_icon_'.$fp_element->parent_id ) != '' ) $features_count++;
						if ( get_option( 'feature_6_icon_'.$fp_element->parent_id ) != '' ) $features_count++;
						
						$features_font_size = get_option( 'features_font_size_'.$fp_element->parent_id );
						
						// for 3 features ( implicit )
						$feature_width = 288;
						$feature_margin = 45;
						
						if ( $features_count == 4 )
						{
							$feature_width = 208;
							$feature_margin = 40;	
						}
						
						if ( $features_count == 5 )
						{
							$feature_width = 170;
							$feature_margin = 25;	
						}
						
						if ( $features_count == 6 )
						{
							$feature_width = 143;
							$feature_margin = 18;	
						}
					
						// initializing links as false
						$link_1_exists = false;
						$link_2_exists = false;
						$link_3_exists = false;
						$link_4_exists = false;
						$link_5_exists = false;
						$link_6_exists = false;
						
						// if the inputs are not empty set the exist variable to true
						if ( get_option( 'feature_1_link_'.$fp_element->parent_id ) != '' ) $link_1_exists = true;
						if ( get_option( 'feature_2_link_'.$fp_element->parent_id ) != '' ) $link_2_exists = true;
						if ( get_option( 'feature_3_link_'.$fp_element->parent_id ) != '' ) $link_3_exists = true;
						if ( get_option( 'feature_4_link_'.$fp_element->parent_id ) != '' ) $link_4_exists = true;
						if ( get_option( 'feature_5_link_'.$fp_element->parent_id ) != '' ) $link_5_exists = true;
						if ( get_option( 'feature_6_link_'.$fp_element->parent_id ) != '' ) $link_6_exists = true;
					
						// start displaying elements
						if ( get_option( 'feature_1_icon_'.$fp_element->parent_id ) != '' )
						{
							if ( $link_1_exists ) echo '<a href="'.get_option( 'feature_1_link_'.$fp_element->parent_id ).'" class="featured_item_link">';
								echo '<div class="featured_item" style="width: '.$feature_width.'px; margin-right: '.$feature_margin.'px;">';
									echo '<div class="featured_item_content">';
										echo '<div class="featured_icon_wrapper">';
											echo '<div class="featured_icon">';
												echo '<img src="'.get_template_directory_uri().'/images/icons/'.get_option( 'feature_1_icon_'.$fp_element->parent_id ).'" alt="Featured Item '.get_option( 'feature_1_text_'.$fp_element->parent_id ).'" />';
											echo '</div>';
										echo '</div>';
										
										echo '<div class="featured_text" style="font-size: '.$features_font_size.'pt !important;">';
											echo get_option( 'feature_1_text_'.$fp_element->parent_id );
										echo '</div>';
									echo '</div>'; // .featured_item_content
								echo '</div>'; // .featured_item
							if ( $link_1_exists ) echo '</a>';
						}
						
						if ( get_option( 'feature_2_icon_'.$fp_element->parent_id ) != '' )
						{
							if ( $link_2_exists ) echo '<a href="'.get_option( 'feature_2_link_'.$fp_element->parent_id ).'" class="featured_item_link">';
								echo '<div class="featured_item" style="width: '.$feature_width.'px; margin-right: '.$feature_margin.'px;">';
									echo '<div class="featured_item_content">';
										echo '<div class="featured_icon_wrapper">';
											echo '<div class="featured_icon">';
												echo '<img src="'.get_template_directory_uri().'/images/icons/'.get_option( 'feature_2_icon_'.$fp_element->parent_id ).'" alt="Featured Item '.get_option( 'feature_2_text_'.$fp_element->parent_id ).'" />';
											echo '</div>';
										echo '</div>';
										
										echo '<div class="featured_text" style="font-size: '.$features_font_size.'pt !important;">';
											echo get_option( 'feature_2_text_'.$fp_element->parent_id );
										echo '</div>';
									echo '</div>'; // .featured_item_content
								echo '</div>'; // .featured_item
							if ( $link_2_exists ) echo '</a>';
						}
						
						if ( get_option( 'feature_3_icon_'.$fp_element->parent_id ) != '' )
						{
							if ( $link_3_exists ) echo '<a href="'.get_option( 'feature_3_link_'.$fp_element->parent_id ).'" class="featured_item_link">';
								echo '<div class="featured_item '.$feature_width.'"'; if ( $features_count != 3 ) echo ' style="width: '.$feature_width.'px; margin-right: '.$feature_margin.'px;"'; echo ' style="width: '.$feature_width.'px;">';
									echo '<div class="featured_item_content">';
										echo '<div class="featured_icon_wrapper">';
											echo '<div class="featured_icon">';
												echo '<img src="'.get_template_directory_uri().'/images/icons/'.get_option( 'feature_3_icon_'.$fp_element->parent_id ).'" alt="Featured Item '.get_option( 'feature_3_text_'.$fp_element->parent_id ).'" />';
											echo '</div>';
										echo '</div>';
										
										echo '<div class="featured_text" style="font-size: '.$features_font_size.'pt !important;">';
											echo get_option( 'feature_3_text_'.$fp_element->parent_id );
										echo '</div>';
									echo '</div>'; // .featured_item_content
								echo '</div>'; // .featured_item
							if ( $link_3_exists ) echo '</a>';
						}
						
						if ( get_option( 'feature_4_icon_'.$fp_element->parent_id ) != '' )
						{
							if ( $link_4_exists ) echo '<a href="'.get_option( 'feature_4_link_'.$fp_element->parent_id ).'" class="featured_item_link">';
								echo '<div class="featured_item '.$feature_width.'"'; if ( $features_count != 4 ) echo ' style="width: '.$feature_width.'px; margin-right: '.$feature_margin.'px;"'; echo ' style="width: '.$feature_width.'px;">';
									echo '<div class="featured_item_content">';
										echo '<div class="featured_icon_wrapper">';
											echo '<div class="featured_icon">';
												echo '<img src="'.get_template_directory_uri().'/images/icons/'.get_option( 'feature_4_icon_'.$fp_element->parent_id ).'" alt="Featured Item '.get_option( 'feature_4_text_'.$fp_element->parent_id ).'" />';
											echo '</div>';
										echo '</div>';
										
										echo '<div class="featured_text" style="font-size: '.$features_font_size.'pt !important;">';
											echo get_option( 'feature_4_text_'.$fp_element->parent_id );
										echo '</div>';
									echo '</div>'; // .featured_item_content
								echo '</div>'; // .featured_item
							if ( $link_4_exists ) echo '</a>';
						}
						
						if ( get_option( 'feature_5_icon_'.$fp_element->parent_id ) != '' )
						{
							if ( $link_5_exists ) echo '<a href="'.get_option( 'feature_5_link_'.$fp_element->parent_id ).'" class="featured_item_link">';
								echo '<div class="featured_item '.$feature_width.'"'; if ( $features_count != 5 ) echo ' style="width: '.$feature_width.'px; margin-right: '.$feature_margin.'px;"'; echo ' style="width: '.$feature_width.'px;">';
									echo '<div class="featured_item_content">';
										echo '<div class="featured_icon_wrapper">';
											echo '<div class="featured_icon">';
												echo '<img src="'.get_template_directory_uri().'/images/icons/'.get_option( 'feature_5_icon_'.$fp_element->parent_id ).'" alt="Featured Item '.get_option( 'feature_5_text_'.$fp_element->parent_id ).'" />';
											echo '</div>';
										echo '</div>';
										
										echo '<div class="featured_text" style="font-size: '.$features_font_size.'pt !important;">';
											echo get_option( 'feature_5_text_'.$fp_element->parent_id );
										echo '</div>';
									echo '</div>'; // .featured_item_content
								echo '</div>'; // .featured_item
							if ( $link_5_exists ) echo '</a>';
						}
						
						if ( get_option( 'feature_6_icon_'.$fp_element->parent_id ) != '' )
						{
							if ( $link_6_exists ) echo '<a href="'.get_option( 'feature_6_link_'.$fp_element->parent_id ).'" class="featured_item_link">';
								echo '<div class="featured_item '.$feature_width.'"'; if ( $features_count != 6 ) echo ' style="width: '.$feature_width.'px; margin-right: '.$feature_margin.'px;"'; echo ' style="width: '.$feature_width.'px;">';
									echo '<div class="featured_item_content">';
										echo '<div class="featured_icon_wrapper">';
											echo '<div class="featured_icon">';
												echo '<img src="'.get_template_directory_uri().'/images/icons/'.get_option( 'feature_6_icon_'.$fp_element->parent_id ).'" alt="Featured Item '.get_option( 'feature_6_text_'.$fp_element->parent_id ).'" />';
											echo '</div>';
										echo '</div>';
										
										echo '<div class="featured_text" style="font-size: '.$features_font_size.'pt !important;">';
											echo get_option( 'feature_6_text_'.$fp_element->parent_id );
										echo '</div>';
									echo '</div>'; // .featured_item_content
								echo '</div>'; // .featured_item
							if ( $link_6_exists ) echo '</a>';
						}
						
					echo '</div>'; // END .front_page_element
				}
			break;
			
			case 'blog':
				$enable_blog = get_option( 'enable_blog_'.$fp_element->parent_id );
				if ( $enable_blog == 'yes' )
				{
					$blog_width = get_option( 'blog_width_'.$fp_element->parent_id );
					$horizontal_splitter += $blog_width;
					
					$margin_class = '';
					if ( $horizontal_splitter == 0.5 )
						$margin_class = 'fp_element_margin_right';
						
					$class = 'half_width_element';
					if ( $blog_width == 1 )
						$class = 'full_width_element';
					
					echo '<div class="front_page_element '.$class.' '.$margin_class.'">';
					
						if ( get_option( 'blog_heading_'.$fp_element->parent_id ) != '' )
						{
							echo '<h3 class="heading">';
								echo get_option( 'blog_heading_'.$fp_element->parent_id );
							echo '</h3>';
						}
					
						$current_categories = get_option( 'blog_categories_'.$fp_element->parent_id );
						$posts_per_page = get_option( 'blog_count_'.$fp_element->parent_id, '3' );
						$elements_per_row = get_option( 'blog_elements_per_row_'.$fp_element->parent_id, '4' );
						$wp_query = new WP_Query('post_type=post&posts_per_page='.$posts_per_page.'&cat='.$current_categories);
						
						global $more;
						$more = 0;

						$blog_post_number = 0;
						
						if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post();
					
							if ( has_post_thumbnail() ) $thumbnail_src = wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) );
						
							if ( $class == 'half_width_element' )
							{
							   $thumbnail_size = 'w=215&amp;h=130';	
							   $div_size = 'width: 215px; height: 130px;';
							}
							
							if ( $class == 'full_width_element' )
							{
								if ( $elements_per_row == '4')
								{
									$thumbnail_size = 'w=217&amp;h=135';
									$div_size = 'width: 217px; height: 135px;';
								}
									
								if ( $elements_per_row == '3')
								{
									$thumbnail_size = 'w=290&amp;h=200';
									$div_size = 'width: 290px; height: 200px;';
								}
							}
						
							$image_source = get_template_directory_uri().'/includes/timthumb.php?src='.$thumbnail_src.'&amp;'.$thumbnail_size.'&amp;zc=1&amp;q=100';
							$image_background_source = get_template_directory_uri().'/includes/timthumb.php?src='.$thumbnail_src.'&amp;'.$thumbnail_size.'&amp;zc=1&amp;q=100&amp;f=2|8|8|8|8|8|8|8';
							
							$blog_post_number++;
							$blog_class = '';
							$blog_second_class = '';
							
							switch($class)
							{
								case 'half_width_element':
									if ( $blog_post_number == $posts_per_page-1 || $blog_post_number == $posts_per_page )
										$blog_class = ' no_margin_bottom';
										
									if ( $blog_post_number %2 == 1 )
										$blog_second_class .= ' margin_right' ;
									
									echo '<article class="blog clearfix'.$blog_class.$blog_second_class.'">';
										echo '<a class="blog_image" href="'; the_permalink(); echo '">';
											echo '<div class="zoom">';
												echo '<span></span>';
											echo '</div>';
											
											echo '<div class="on_top" style="'.$div_size.' background: url(\''; echo $image_source; echo '\');"></div>';
											echo '<div class="on_middle" style="'.$div_size.' background: url(\''; echo $image_background_source; echo '\');"></div>';
											echo '<div class="above_bottom" style="'.$div_size.' background: url(\''; echo $image_source; echo '\');"></div>';
											echo '<div class="on_bottom"></div>';
										echo '</a>';
										
										echo '<a class="header" href="'; the_permalink(); echo '">';
											echo '<h4>';
												echo the_title();
											echo '</h4>';
										echo '</a>';
										
										echo the_content('');
										
										echo '<div class="read_more">';
											echo '<a href="'; the_permalink(); echo '">';
												echo '<span class="read_more_arrow"></span>';
												echo __( 'Read more', 'reFresh' );
											echo '</a>';
										echo '</div>';
									echo '</article>';
								break;
								
								case 'full_width_element':
								
									if ( $elements_per_row == 4 )
									{
										if ( $blog_post_number == $posts_per_page-3 || $blog_post_number == $posts_per_page-2 || $blog_post_number == $posts_per_page-1 || $blog_post_number == $posts_per_page )
											$blog_class = ' no_margin_bottom';
										
										if ( $blog_post_number %4 != 0 )
											$blog_second_class .= ' margin_right' ;
											
										$blog_class .= ' small_element';
									}
									
									if ( $elements_per_row == 3 )
									{
										if ( $blog_post_number == $posts_per_page-2 || $blog_post_number == $posts_per_page-1 || $blog_post_number == $posts_per_page )
											$blog_class = ' no_margin_bottom';
										
										if ( $blog_post_number %3 != 0 )
											$blog_second_class .= ' margin_right' ;
											
										$blog_class .= ' big_element';
									}
									
									echo '<article class="blog clearfix'.$blog_class.$blog_second_class.'">';
										echo '<a class="blog_image" href="'; the_permalink(); echo '">';
											echo '<div class="zoom">';
												echo '<span></span>';
											echo '</div>';
											
											echo '<div class="on_top" style="'.$div_size.' background: url(\''; echo $image_source; echo '\');"></div>';
											echo '<div class="on_middle" style="'.$div_size.' background: url(\''; echo $image_background_source; echo '\');"></div>';
											echo '<div class="above_bottom" style="'.$div_size.' background: url(\''; echo $image_source; echo '\');"></div>';
											echo '<div class="on_bottom"></div>';
										echo '</a>';
										
										echo '<a class="header" href="'; the_permalink(); echo '">';
											echo '<h4>';
													echo the_title();
											echo '</h4>';
										echo '</a>';
										
										echo the_content('');
										
										echo '<div class="read_more">';
											echo '<a href="'; the_permalink(); echo '">';
												echo '<span class="read_more_arrow"></span>';
												echo __( 'Read more', 'reFresh' );
											echo '</a>';
										echo '</div>';
										
										echo '<div class="date">';
											echo get_the_date('jS F Y'); 
										echo '</div>';

									echo '</article>';
								break;
							} // END switch($class)
							
							switch($class)
							{
								case 'half_width_element':
									if ( $blog_post_number %2 == 0)
										echo '<div class="horizontal_splitter"></div>';
								break;
								
								case 'full_width_element':
									if ( $blog_post_number %4 == 0 && $elements_per_row != 3)
									{
										echo '<div class="horizontal_splitter"></div>';
									}
									
									if ( $blog_post_number %3 == 0 && $elements_per_row == 3)
									{
										echo '<div class="horizontal_splitter"></div>';
									}
								break;
							}
						endwhile; endif;
				
					
					echo '</div>'; // END .front_page_element
				}
			break;
			
			case 'slideshow':
				$enable_slideshow = get_option( 'enable_slideshow_'.$fp_element->parent_id );
				if ( $enable_slideshow == 'yes' )
				{
					$slideshow_width = get_option( 'slideshow_width_'.$fp_element->parent_id );
					$horizontal_splitter += $slideshow_width;
					
					$margin_class = '';
					if ( $horizontal_splitter == 0.5 )
						$margin_class = 'fp_element_margin_right';
					
					$class = 'half_width_element';
					if ( $slideshow_width == 1 )
						$class = 'full_width_element';
					
					
					
					echo '<div class="front_page_element '.$class.' '.$margin_class.'">';
					
						if ( get_option( 'slideshow_heading_'.$fp_element->parent_id ) != '' )
						{
							echo '<h3 class="heading">';
								echo get_option( 'slideshow_heading_'.$fp_element->parent_id );
							echo '</h3>';
						}
					
						$current_categories    = get_option( 'slideshow_categories_'.$fp_element->parent_id );
						$posts_per_page        = get_option( 'slideshow_count_'.$fp_element->parent_id, '3' );
						$slideshow_transitions = get_option( 'slideshow_transitions_'.$fp_element->parent_id, 'random' );
						$slideshow_pausetime   = get_option( 'slideshow_pausetime_'.$fp_element->parent_id, '10000' );
						$wp_query = new WP_Query('post_type=post&posts_per_page='.$posts_per_page.'&cat='.$current_categories);

						// remove ms and white spaces
						$slideshow_pausetime = str_replace('ms', '', $slideshow_pausetime);
						$slideshow_pausetime = str_replace(' ', '', $slideshow_pausetime);
						
						if ( $wp_query->have_posts() ) :
						
							echo '<script type="text/javascript">
									jQuery(window).load(function() {
										jQuery(document).ready(function($) {
											jQuery(".front_page_slideshow").nivoSlider({
														controlNav:true, 
														directionNavHide:false, 
														slices:10, 
														boxCols:4, 
														boxRows:4, 
														animSpeed:800, 
														pauseTime:'.$slideshow_pausetime.',
														effect:\''.$slideshow_transitions.'\'
											});
										});
									});';
							echo '</script>';
						
						
							echo '<div class="front_page_slideshow" style="height: '.get_option( 'slideshow_height_'.$fp_element->parent_id ).'px; overflow: hidden;">';
								while ( $wp_query->have_posts() ) : $wp_query->the_post();
						
								if ( has_post_thumbnail() ) $thumbnail_src = wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) );
								
								if ( $class == 'half_width_element' )  $thumbnail_size = 'w=455&amp;h='.get_option( 'slideshow_height_'.$fp_element->parent_id );
								if ( $class == 'full_width_element' )  $thumbnail_size = 'w=960&amp;h='.get_option( 'slideshow_height_'.$fp_element->parent_id );
								
								$image_source = get_template_directory_uri().'/includes/timthumb.php?src='.$thumbnail_src.'&amp;'.$thumbnail_size.'&amp;zc=1&amp;q=100';
								
								echo '<a href="'; echo $thumbnail_src; echo '" rel="prettyPhoto[front_page_slideshow]">';
									echo '<img src="'.$image_source.'" alt="'; echo the_title(); echo '" />';
								echo '</a>';
								endwhile;
								
							echo '</div>';
							
							// The Thumbnails
							echo '<div class="nivo_small_thumbnails">';
								for ( $i = 0; $i < $posts_per_page; $i++)
									echo '<a rel="'.$i.'" >'.$i.'</a>';
							echo '</div>';
							
							if ( get_option( 'slideshow_description_'.$fp_element->parent_id ) != '' )
							{
								echo '<div class="fp_slideshow_description">';
									echo get_option( 'slideshow_description_'.$fp_element->parent_id );
								echo '</div>';
							}
						endif;

					echo '</div>'; // END .front_page_element
				}
			break;
			
			case 'news':
				$enable_news = get_option( 'enable_news_'.$fp_element->parent_id );
				if ( $enable_news == 'yes' )
				{
					$news_width = get_option( 'news_width_'.$fp_element->parent_id );
					$horizontal_splitter += $news_width;
					
					$margin_class = '';
					if ( $horizontal_splitter == 0.5 )
						$margin_class = 'fp_element_margin_right';
					
					$class = 'half_width_element';
					if ( $news_width == 1 )
						$class = 'full_width_element';
					
					echo '<div class="front_page_element '.$class.' '.$margin_class.'">';
					
						if ( get_option( 'news_heading_'.$fp_element->parent_id ) != '' )
						{
							echo '<h3 class="heading">';
								echo get_option( 'news_heading_'.$fp_element->parent_id );
							echo '</h3>';
						}
						
						$current_categories = get_option( 'news_categories_'.$fp_element->parent_id );
						$posts_per_page = get_option( 'news_count_'.$fp_element->parent_id, '3' );

						$wp_query = new WP_Query('post_type=post&posts_per_page='.$posts_per_page.'&cat='.$current_categories);
						
						global $more;
						$more = 0;
						
						$article_number = 0;
						
						if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post();
					
							if ( has_post_thumbnail() ) $thumbnail_src = wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) );
						
							if ( $class == 'half_width_element' )   $thumbnail_size = 'w=140&amp;h=90';
							if ( $class == 'full_width_element' )	$thumbnail_size = 'w=140&amp;h=90';
						
							$image_source = get_template_directory_uri().'/includes/timthumb.php?src='.$thumbnail_src.'&amp;'.$thumbnail_size.'&amp;zc=1&amp;q=100';
							
							$article_number++;
							
							$article_class = '';
							if ( ($article_number == $posts_per_page) || ($article_number == 1 && $class == 'full_width_element')  )
								$article_class = ' no_margin_bottom';
							
							switch($class)
							{
								case 'half_width_element':
								
								$news_article_add_styling = '';
								if ( $article_number == 1 )
									$news_article_add_styling = 'style="padding-top: 0px !important; border-top: 0px !important;"';
								
									echo '<article class="news clearfix small_element'.$article_class.'" '.$news_article_add_styling.'>';
										echo '<div class="news_left">';
											echo '<a class="news_image" href="'; the_permalink(); echo '">';
												echo '<img src="'.$image_source.'" alt="'; echo the_title(); echo '" />';
											echo '</a>';
											
											echo '<div class="news_meta">';
												echo '<span>';
														echo __( 'Posted on: ', 'reFresh' ); 
														
														$arc_year = get_the_date('Y'); 
														$arc_month = get_the_date('M'); 
														
														echo '<a href="'; echo get_month_link( $arc_year, $arc_month ); echo '">';
															echo get_the_date('jS F Y'); 
														echo '</a>';
														
													echo '</span>';
												echo '<span>';
													echo __( 'Posted in: ', 'reFresh' ); the_category(', ');
												echo '</span>';
												the_tags('<span>Tags: ',', ','</span>');
											echo '</div>';
										echo '</div>';
										echo '<div class="news_content clearfix">';
										echo '<a class="header" href="'; the_permalink(); echo '">';
											echo '<h4>';
													echo the_title();
											echo '</h4>';
											echo '</a>';
											echo the_content('');
											echo '<div class="read_more">';
												echo '<a href="'; the_permalink(); echo '">';
													echo '<span class="read_more_arrow"></span>';
													echo __( 'Read more', 'reFresh' );
												echo '</a>';
											echo '</div>';
										echo '</div>';
									echo '</article>';
								break;
								
								case 'full_width_element';
									if ( $article_number == 1 )
									{
										
										$news_article_add_styling = '';
										if ( get_option( 'news_heading_'.$fp_element->parent_id ) == '' )
											$news_article_add_styling = 'style="padding-top: 0px !important; border-top: 0px !important;"';
											
										echo '<article class="news clearfix big_element first_element'.$article_class.'" '.$news_article_add_styling.'>';
											echo '<div class="news_left">';
												echo '<a class="news_image" href="'; the_permalink(); echo '">';
													$image_source = get_template_directory_uri().'/includes/timthumb.php?src='.$thumbnail_src.'&amp;w=447&amp;h=190&amp;zc=1&amp;q=100';
													echo '<img src="'.$image_source.'" alt="'; echo the_title(); echo '" />';
												echo '</a>';
												
												echo '<div class="news_meta">';
													echo '<span>';
														echo __( 'Posted on: ', 'reFresh' ); 
														
														$arc_year = get_the_date('Y');
														$arc_month = get_the_date('m');
														
														echo '<a href="'; echo get_month_link( $arc_year, $arc_month ); echo '">';
															echo get_the_date('jS F Y'); 
														echo '</a>';
														
													echo '</span>';
													echo '<span>';
														echo __( 'Posted in: ', 'reFresh' ); the_category(', ');
													echo '</span>';
													the_tags('<span>Tags: ',', ','</span>');
												echo '</div>';
											echo '</div>';
											echo '<div class="news_content clearfix">';
											echo '<a class="header" href="'; the_permalink(); echo '">';
												echo '<h4>';
														echo the_title();
												echo '</h4>';
												echo '</a>';
												echo the_content('');
												echo '<div class="read_more">';
													echo '<a href="'; the_permalink(); echo '">';
														echo '<span class="read_more_arrow"></span>';
														echo __( 'Read more', 'reFresh' );
													echo '</a>';
												echo '</div>';
											echo '</div>';
										echo '</article>';
									} // END if ( $article_number == 1 )
									
									else // if ( $article_number == 1 )
									{
										$news_article_add_styling = '';
										if ( get_option( 'news_heading_'.$fp_element->parent_id ) == '' && $article_number == 2 )
											$news_article_add_styling = 'style="padding-top: 0px !important; border-top: 0px !important;"';
										
										echo '<article class="news clearfix big_element'.$article_class.'" '.$news_article_add_styling.'>';
											echo '<div class="news_left">';
												echo '<a class="news_image" href="'; the_permalink(); echo '">';
													echo '<img src="'.$image_source.'" alt="'; echo the_title(); echo '" />';
												echo '</a>';
												
												echo '<div class="news_meta">';
													echo '<span>';
														echo __( 'Posted on: ', 'reFresh' ); 
														
														$arc_year = get_the_date('Y');
														$arc_month = get_the_date('m');
														
														echo '<a href="'; echo get_month_link( $arc_year, $arc_month ); echo '">';
															echo get_the_date('jS F Y'); 
														echo '</a>';
														
													echo '</span>';
													echo '<span>';
														echo __( 'Posted in: ', 'reFresh' ); the_category(', ');
													echo '</span>';
													the_tags('<span>Tags: ',', ','</span>');
												echo '</div>';
											echo '</div>';
											echo '<div class="news_content clearfix">';
											echo '<a class="header" href="'; the_permalink(); echo '">';
												echo '<h4>';
														echo the_title();
												echo '</h4>';
												echo '</a>';
												echo the_content('');
												echo '<div class="read_more">';
													echo '<a href="'; the_permalink(); echo '">';
														echo '<span class="read_more_arrow"></span>';
														echo __( 'Read more', 'reFresh' );
													echo '</a>';
												echo '</div>';
											echo '</div>';
										echo '</article>';
									} // END else if ( $article_number == 1 )
									
								break;
							} // END switch($class)
							
					
						endwhile; endif;
				
					
					echo '</div>'; // END .front_page_element
				}
			break;
			
			case 'tabs':
				$enable_tabs = get_option( 'enable_tabs_'.$fp_element->parent_id );
				if ( $enable_tabs == 'yes' )
				{
					$tabs_width = get_option( 'tabs_width_'.$fp_element->parent_id );
					$horizontal_splitter += $tabs_width;
					
					$margin_class = '';
					if ( $horizontal_splitter == 0.5 )
						$margin_class = 'fp_element_margin_right';
					
					$class = 'half_width_element';
					if ( $tabs_width == 1 )
						$class = 'full_width_element';
					
					$tabs_exist = false;
					if ( get_option( 'tab_1_title_'.$fp_element->parent_id ) != '' || get_option( 'tab_2_title_'.$fp_element->parent_id ) != '' ||
						 get_option( 'tab_3_title_'.$fp_element->parent_id ) != '' || get_option( 'tab_4_title_'.$fp_element->parent_id ) != '' )
					{
						$tabs_exist = true;
					}
						
						
					echo '<div class="front_page_element '.$class.' '.$margin_class.'">';
					
						if ( get_option( 'tabs_heading_'.$fp_element->parent_id ) != '' )
						{
							echo '<h3 class="heading">';
								echo get_option( 'tabs_heading_'.$fp_element->parent_id );
							echo '</h3>';
						}
						
						if ( $tabs_exist )
						{
							
							echo '<div class="tabs">';
								echo '<ul>';
									if ( get_option( 'tab_1_title_'.$fp_element->parent_id ) != '' )
									{
										echo '<li>';
											echo '<a href="#front_page_tab_1">';
												echo get_option( 'tab_1_title_'.$fp_element->parent_id );
											echo '</a>';
										echo '</li>';
									}
									
									if ( get_option( 'tab_2_title_'.$fp_element->parent_id ) != '' )
									{
										echo '<li>';
											echo '<a href="#front_page_tab_2">';
												echo get_option( 'tab_2_title_'.$fp_element->parent_id );
											echo '</a>';
										echo '</li>';
									}
									
									if ( get_option( 'tab_3_title_'.$fp_element->parent_id ) != '' )
									{
										echo '<li>';
											echo '<a href="#front_page_tab_3">';
												echo get_option( 'tab_3_title_'.$fp_element->parent_id );
											echo '</a>';
										echo '</li>';
									}
									
									if ( get_option( 'tab_4_title_'.$fp_element->parent_id ) != '' )
									{
										echo '<li>';
											echo '<a href="#front_page_tab_4">';
												echo get_option( 'tab_4_title_'.$fp_element->parent_id );
											echo '</a>';
										echo '</li>';
									}
									
									echo '<li class="last"></li>';
								echo '</ul>';
								
								if ( get_option( 'tab_1_title_'.$fp_element->parent_id ) != '' )
								{
									echo '<div id="front_page_tab_1" class="tab_content">';
										echo get_option( 'tab_1_content_'.$fp_element->parent_id );
									echo '</div>';
								}
								
								if ( get_option( 'tab_2_title_'.$fp_element->parent_id ) != '' )
								{
									echo '<div id="front_page_tab_2" class="tab_content">';
										echo get_option( 'tab_2_content_'.$fp_element->parent_id );
									echo '</div>';
								}
								
								if ( get_option( 'tab_3_title_'.$fp_element->parent_id ) != '' )
								{
									echo '<div id="front_page_tab_3" class="tab_content">';
										echo get_option( 'tab_3_content_'.$fp_element->parent_id );
									echo '</div>';
								}
								
								if ( get_option( 'tab_4_title_'.$fp_element->parent_id ) != '' )
								{
									echo '<div id="front_page_tab_4" class="tab_content">';
										echo get_option( 'tab_4_content_'.$fp_element->parent_id );
									echo '</div>';
								}
								
							echo '</div>'; // END .front_page_tabs
						} // END if ( $tabs_exist )
						
					echo '</div>'; // END .front_page_element
				}
			break;
			
			case 'testimonials':
				$enable_testimonials = get_option( 'enable_testimonials_'.$fp_element->parent_id );
				if ( $enable_testimonials == 'yes' )
				{
					$testimonials_width = get_option( 'testimonials_width_'.$fp_element->parent_id );
					$horizontal_splitter += $testimonials_width;
					
					$margin_class = '';
					if ( $horizontal_splitter == 0.5 )
						$margin_class = 'fp_element_margin_right';
					
					$class = 'half_width_element';
					if ( $testimonials_width == 1 )
						$class = 'full_width_element';
					
					$testimonials_exist = false;
					if ( get_option( 'testimonial_1_text_'.$fp_element->parent_id ) != '' )
						$testimonials_exist = true;

						
					echo '<div class="front_page_element '.$class.' '.$margin_class.'">';
					
						if ( get_option( 'testimonials_heading_'.$fp_element->parent_id ) != '' )
						{
							echo '<h3 class="heading">';
								echo get_option( 'testimonials_heading_'.$fp_element->parent_id );
							echo '</h3>';
						}
						
						if ( $testimonials_exist )
						{
							echo '<div class="testimonials clearfix">';
								
								if ( $testimonials_width != '0.5' )
								{
									if ( get_option( 'testimonial_1_text_'.$fp_element->parent_id ) != '' )
									{
										echo '<div class="big_testimonials_left clearfix">';
											echo '<div class="testimonial_text">';
												echo get_option( 'testimonial_1_text_'.$fp_element->parent_id );
											echo '</div>';
											echo '<a class="contact_person" href="'.get_option( 'testimonial_1_link_'.$fp_element->parent_id ).'">'.get_option( 'testimonial_1_person_'.$fp_element->parent_id ).'</a>';
										echo '</div>';
									}
									
									if ( get_option( 'testimonial_2_text_'.$fp_element->parent_id ) != '' )
									{
										echo '<div class="big_testimonials_right">';
											echo '<div class="right_element clearfix">';
												echo '<div class="testimonial_text">';
													echo get_option( 'testimonial_2_text_'.$fp_element->parent_id );
												echo '</div>';
												echo '<a class="contact_person" href="'.get_option( 'testimonial_2_link_'.$fp_element->parent_id ).'">'.get_option( 'testimonial_2_person_'.$fp_element->parent_id ).'</a>';
											echo '</div>';
												
											if ( get_option( 'testimonial_3_text_'.$fp_element->parent_id ) != '' )
											{
												echo '<div class="right_element clearfix third_element">';
													echo '<div class="testimonial_text">';
														echo get_option( 'testimonial_3_text_'.$fp_element->parent_id );
													echo '</div>';
													echo '<a class="contact_person" href="'.get_option( 'testimonial_3_link_'.$fp_element->parent_id ).'">'.get_option( 'testimonial_3_person_'.$fp_element->parent_id ).'</a>';
												echo '</div>';
											}
											
										echo '</div>';
									}
								} // END if ( $testimonials_width != '0.5' )
								
								else
								{
									echo '<div class="small_testimonials clearfix">';
										echo '<div class="testimonial_text">';
											echo get_option( 'testimonial_1_text_'.$fp_element->parent_id );
										echo '</div>';
										echo '<a class="contact_person" href="'.get_option( 'testimonial_1_link_'.$fp_element->parent_id ).'">'.get_option( 'testimonial_1_person_'.$fp_element->parent_id ).'</a>';
									echo '</div>';
									
									if ( get_option( 'testimonial_2_text_'.$fp_element->parent_id ) != '' )
									{
										echo '<div class="small_testimonials clearfix more_elements">';
											echo '<div class="testimonial_text">';
												echo get_option( 'testimonial_2_text_'.$fp_element->parent_id );
											echo '</div>';
											echo '<a class="contact_person" href="'.get_option( 'testimonial_2_link_'.$fp_element->parent_id ).'">'.get_option( 'testimonial_2_person_'.$fp_element->parent_id ).'</a>';
										echo '</div>';
										
										if ( get_option( 'testimonial_3_text_'.$fp_element->parent_id ) != '' )
										{
											echo '<div class="small_testimonials clearfix more_elements">';
												echo '<div class="testimonial_text">';
													echo get_option( 'testimonial_3_text_'.$fp_element->parent_id );
												echo '</div>';
												echo '<a class="contact_person" href="'.get_option( 'testimonial_3_link_'.$fp_element->parent_id ).'">'.get_option( 'testimonial_3_person_'.$fp_element->parent_id ).'</a>';
											echo '</div>';
										}
									}
									
								} // END else if ( $testimonials_width != '0.5' )
								
							echo '</div>'; // END .testimonials
						} // END if ( $tabs_exist )
						
					echo '</div>'; // END .front_page_element
				}
			break;
			
			case 'contact':
				$enable_contact = get_option( 'enable_contact_'.$fp_element->parent_id );
				if ( $enable_contact == 'yes' )
				{
					$contact_width = 0.5;
					$horizontal_splitter += $contact_width;
					
					$margin_class = '';
					if ( $horizontal_splitter == 0.5 )
						$margin_class = 'fp_element_margin_right';
					
					$class = 'half_width_element';
					
					echo '<div class="front_page_element '.$class.' '.$margin_class.'">';
					
						if ( get_option( 'contact_heading_'.$fp_element->parent_id ) != '' )
						{
							echo '<h3 class="heading">';
								echo get_option( 'contact_heading_'.$fp_element->parent_id );
							echo '</h3>';
						}
						
						if ( get_option( 'enable_recaptcha_'.$fp_element->parent_id ) == 'yes' )
						{
							include('includes/recaptchalib.php'); 
							
							echo '<script type="text/javascript">';
								echo 'var RecaptchaOptions = {';
									echo 'theme : \'custom\',';
									echo 'custom_theme_widget: \'recaptcha_widget\'';
								echo '};';
							echo '</script>';
						}
						 
						?>
                 
               
						<script type="text/javascript">
                                
                            jQuery(document).ready(function() {
                                
                                // validator
                                $("#contact_form").validate();
                                
                                // ajax stuff	
                                jQuery(".re_captcha_submit").click(function(){
                                    jQuery('#contact_form .message_area').html('');
                                });
                                jQuery('#contact_form').ajaxForm({
                                    target: '#contact_form .message_area'
                                    <?php if ( get_option( 'enable_recaptcha_'.$fp_element->parent_id ) == 'yes' ) echo ',success: result_function'; ?>
                                });
                                
                                jQuery('#contact_form .message_area').show('fast');
                                
                                function result_function() {
                                    Recaptcha.reload();	
                                    
                                    var repeat_turn_black = 2;
                                    while ( repeat_turn_black != 0 )
                                    {
                                        setTimeout(function() {
                                            turn_black();
                                        }, 100);
                                        repeat_turn_black--;
                                    }
                                }
                                
                            });
                        </script>
						
						
						<form id="contact_form" method="post" class="clearfix jqtransformdone" action="<?php echo get_template_directory_uri(); ?>/page_contact_sender.php">
                        
                            <?php 
                            
                            $destination_email = get_option('destination_email');
                            if ( $destination_email == '' )
                                $destination_email = get_bloginfo('admin_email');
                            else $destination_email = get_option('destination_email');
        
                            ?>
                            <input type="hidden" name="destination_email" value="<?php echo $destination_email; ?>" />
                            <?php 
                                if ( get_option('form_title') != '' )
                                {
                                    echo '<h1>';
                                        echo get_option('form_title');
                                    echo '</h1>';
                                }
                            ?>
                            <div id="fpm_contact_name" class="form_input form_left clearfix">  
                                <span class="icon_name"><span>Name</span></span>
                                <span class="icon_name_hover"></span>
                                <input id="name" type="text" name="name" <?php if (get_option('contact_name_required') == 'yes') echo 'class="required"'; ?> />
                            </div>
                            <div id="fpm_contact_email" class="form_input form_right clearfix">
                                <span class="icon_email"><span>e-mail</span></span>
                                <span class="icon_email_hover"></span>
                                <input id="email" type="text" name="email" class="required email" />
                            </div>
                            <div id="fpm_contact_company" class="form_input form_left clearfix">
                                <span class="icon_company"><span>Company</span></span>
                                <span class="icon_company_hover"></span>
                                <input id="company" type="text" name="company" <?php if (get_option('contact_company_required') == 'yes') echo 'class="required"'; ?> />
                            </div>
                            <div id="fpm_contact_phone" class="form_input form_right clearfix">
                                <span class="icon_phone"><span>Phone Number</span></span>   
                                <span class="icon_phone_hover"></span>
                                <input id="phone" type="text" name="phone" <?php if (get_option('contact_phone_required') == 'yes') echo 'class="required"'; ?> />
                            </div>
                            <div class="form_element clearfix">
                                <textarea id="message" rows="10" cols="60" spellcheck="false" name="message" class="required"></textarea>
                            </div>
                            
                            <?php
                            
                            if ( get_option( 'enable_recaptcha_'.$fp_element->parent_id ) == 'yes' )
                            {
                                echo '<div id="recaptcha_widget" style="display:none">';
            
                                    echo '<div id="recaptcha_left">';
                                        echo '<span>';
                                            echo __( 'Read this:', 'reFresh' );
                                        echo '</span>';
                                        echo '<div id="recaptcha_image"></div>';
                                    echo '</div>';
                                    
                                        echo '<div class="recaptcha_only_if_incorrect_sol" style="color:red">Incorrect please try again</div>';
                                    
                                    echo '<div id="recaptcha_middle">';
                                        echo '<div class="get_another_captcha"><a href="Recaptcha.reload()">Get another CAPTCHA</a></div>';
                                        echo '<div class="switch_to_audio recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type(\'audio\')">Get an audio CAPTCHA</a></div>';
                                        echo '<div class="switch_to_video recaptcha_only_if_audio"><a href="javascript:switch_to_image()">Get an image CAPTCHA</a></div>';
                                        echo '<div class="captcha_help"><a href="javascript:Recaptcha.showhelp()">Help</a></div>';
                                    echo '</div>';
                                    
                                    echo '<div id="recaptcha_right">';
                                        echo '<span class="recaptcha_only_if_image">';
                                            echo __( 'Enter the words here:', 'reFresh' );
                                        echo '</span>';
                                        echo '<span class="recaptcha_only_if_audio">';
                                            echo __( 'Enter the numbers you hear:', 'reFresh' );
                                        echo '</span>';
                                        echo '<input type="text" id="recaptcha_response_field" name="recaptcha_response_field" />';
                                    echo '</div>';
                            
                                echo '</div>';
                              
                                echo '<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k='; echo get_option('recaptcha_public_key'); echo '"></script>';
                                echo '<noscript>';
                                    echo '<iframe src="http://www.google.com/recaptcha/api/noscript?k='; echo get_option('recaptcha_public_key'); echo'" height="300" width="500" frameborder="0"></iframe>';
                                    echo '<br>';
                                    echo '<textarea name="recaptcha_challenge_field" rows="3" cols="40">';
                                    echo '</textarea>';
                                    echo '<input type="hidden" name="recaptcha_response_field" value="manual_challenge">';
                                echo '</noscript>';
                                
                             } // END if ( get_option( 'enable_recaptcha_'.$fp_element->parent_id ) == 1 )
                             ?>
                            
                            <div class="submit_area">
                                <input type="submit" class="re_captcha_submit" value="<?php echo __('Send Message','reFresh'); ?>">
                            </div>
                            <div class="message_area"></div>
                        </form>
                    
                    <?php

					echo '</div>';
				}
			break;
			
			case 'custom':
				$enable_custom = get_option( 'enable_custom_'.$fp_element->parent_id );
				if ( $enable_custom == 'yes' )
				{
					$custom_width = get_option( 'custom_width_'.$fp_element->parent_id );
					$horizontal_splitter += $custom_width;
					
					$margin_class = '';
					if ( $horizontal_splitter == 0.5 )
						$margin_class = 'fp_element_margin_right';
					
					$class = 'half_width_element';
					if ( $custom_width == 1 )
						$class = 'full_width_element';
					
					echo '<div class="front_page_element '.$class.' '.$margin_class.'">';
					
						echo '<article class="custom_element">';
							if ( get_option( 'custom_heading_'.$fp_element->parent_id ) != '' )
							{
								echo '<h3 class="heading">';
									echo get_option( 'custom_heading_'.$fp_element->parent_id );
								echo '</h3>';
							}
							echo '<div class="custom_content">';
								echo do_shortcode( get_option( 'custom_content_'.$fp_element->parent_id ) );
							echo '</div>';
						echo '</article>';
					echo '</div>';
				}
			break;
			
			case 'the_content':
				$enable_the_content = get_option( 'enable_the_content_'.$fp_element->parent_id );
				if ( $enable_the_content == 'yes' )
				{
					$the_content_width = get_option( 'the_content_width_'.$fp_element->parent_id );
					$horizontal_splitter += $the_content_width;
					
					$margin_class = '';
					if ( $horizontal_splitter == 0.5 )
						$margin_class = 'fp_element_margin_right';
					
					$class = 'half_width_element';
					if ( $the_content_width == 1 )
						$class = 'full_width_element';
					
					echo '<div class="front_page_element '.$class.' '.$margin_class.'">';
					
						if ( get_option( 'display_the_content_title_'.$fp_element->parent_id ) == 'yes' )
						{
							echo '<h3 class="heading">';
								echo $the_page_title;
							echo '</h3>';
						}
						
						echo $the_page_content;
						
					echo '</div>';
				}
			break;
		}  // END switch
		
	} // END foreach ($display_fp_elements as $display_fp_element)
	
	echo '</section>'; // END #content_wrapper
	
} // END if ( $display_fp_elements != '' )


get_footer();

?>